<template>
  <div class="header">

    <!--<div class="h-right">-->
      <!--<el-popover-->
        <!--width="200"-->
        <!--placement="bottom"-->
        <!--trigger="click">-->
        <!--<div>-->
          <!--<p>最近一周您有<span>1</span>条通知</p>-->
          <!--<ul class="message-ul">-->
            <!--<li>testtest</li>-->
            <!--<li>testtest</li>-->
          <!--</ul>-->
          <!--<a href="javascript:;" class="message-footer">查看所有通知</a>-->
        <!--</div>-->
        <!--<div slot="reference">-->
          <!--<i class="el-icon-message"></i>-->
          <!--<el-badge :value="1" class="item" type="primary">-->
            <!--<el-button size="small">通知</el-button>-->
          <!--</el-badge>-->
        <!--</div>-->
      <!--</el-popover>-->
      <!--<span>-->
      <!--<i class="el-icon-bell"></i>-->
      <!--<el-badge :value="1" class="item">-->
        <!--<el-button size="small">公告</el-button>-->
      <!--</el-badge>-->
      <!--</span>-->
      <!--<span>-->
      <!--<img-->
        <!--src=""/>-->
      <!--<el-badge class="item" type="primary">-->
        <!--<el-button size="small">修改密码</el-button>-->
      <!--</el-badge>-->
      <!--</span>-->
      <!--<span>-->
      <!--<img-->
        <!--src=""/>-->
      <!--<el-badge class="item" type="primary">-->
        <!--<el-button size="small">修改密码</el-button>-->
      <!--</el-badge>-->
      <!--</span>-->
      <!--<span>-->
      <!--<img-->
        <!--src=""/>-->
      <!--<el-badge class="item" type="primary">-->
        <!--<el-button size="small">修改密码</el-button>-->
      <!--</el-badge>-->
      <!--</span>-->
    <!--</div>-->
    <div class="h-left">
      <span v-if="visualImg" class="logo-mini">
        <img src="../assets/img/logo.png" style="width:40px;height:auto;">
      </span>
      <span v-if="!visualImg" class="logo-lg">
        <img src="../assets/img/logo.png" style="height: 32px;width:auto;margin: 10px 0 0 50px;">
      </span>
    </div>
    <el-menu
            class="el-menu-header"
            mode="horizontal"
            router :default-active="$route.path"
            background-color="rgb(52, 55, 68)"
            text-color="#fff"
            active-text-color="#ffd04b"
    >
      <el-menu-item
              v-for="value in this.menuData"
              :key="value.id"
              :index="value.navigateUrl"
              @click="handleSelect(value)"
      >
        {{value.name}}
      </el-menu-item>
    </el-menu>
    <el-menu
            class="el-menu-header-right"
            mode="horizontal"
            router :default-active="$route.path"
            background-color="rgb(52, 55, 68)"
            text-color="#fff"
            active-text-color="#ffd04b"
    >
      <el-submenu index="1">
        <template slot="title">超级管理员</template>
        <el-menu-item index="1-1">个人资料</el-menu-item>
        <el-menu-item index="1-2">退出</el-menu-item>
      </el-submenu>
    </el-menu>
  </div>
</template>

<script>
    import api from '@/api/api';
    import http from '@/http'
    import Bus from '../Bus.js'

    export default {
    data() {
      return {
          userInfo: null,
          userName: "",
          activeIndex: '',
          visualImg:false,
          menuData:[]
      };
    },
      mounted: function () {
          this.$http2.get(api.findMenuByUserAndParentId+'?userId=1', {
          })
              .then(data => {
                  this.menuData = data.data;
              }).catch(() => {
              console.log("失败");
          });
      },
    methods: {
        handleSelect(item) {
//            if(item.navigateUrl==''){
                Bus.$emit('on', item);
//            }
        }
    },
  };
</script>
<style lang="less">
  .el-menu.el-menu--horizontal{
    border-bottom: 0!important;
    height: 50px;
  }
  .el-menu--horizontal>.el-submenu .el-submenu__title,.el-menu--horizontal>.el-menu-item{
    height: 50px!important;
    line-height: 50px!important;
    border-left: 1px #545559 solid;
    border-right: 1px #1a1d24 solid;
  }
  .el-menu-header-right>.el-submenu .el-submenu__title,.el-menu-header-right>.el-menu-item{
    height: 50px!important;
    line-height: 50px!important;
    border-left: 0;
    border-right: 0;
  }
  .el-menu-header{
    float: left;
    margin-left: 50px;
  }
  .el-menu-header-right{
    float: right;
  }
  .header {
    background-color: #343744;
    border: 0;
    height: 50px;
    .el-menu-item:hover{
      background: rgb(20, 21, 26)!important;
    }
    .el-submenu__title:hover{
      background: rgb(20, 21, 26)!important;
    }
    .h-left{
      float: left;
      width: 230px;
    }
    .h-right {
      float: right;
      margin-top: 10px;
      > span {
        color: #fff;
        display: inline-block;
        margin-right: 20px;
        img, i {
          vertical-align: middle;
        }
      }
    }
    .el-button--small, .el-button--small.is-round {
      padding: 9px 6px 9px 0;
      background: transparent;
      border: 0;
      color: #fff;
    }
    .el-badge__content {
      border-radius: 4px;
      padding: 0 4px;
      margin-top: 6px;
      height: 14px;
      line-height: 14px;
      border: 0;
    }
  }
  .message-footer{
    text-align: center;
    display: block;
    text-decoration: none;
  }
  .message-ul li{
    height: 40px;
    line-height: 40px;
  }
  .message-ul li:hover{
    background: #f4f4f4;
    cursor: pointer;
  }
</style>
